<template>
    <div class="app-box">
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>我的申请</el-breadcrumb-item>
            <el-breadcrumb-item>请假信息</el-breadcrumb-item>
        </el-breadcrumb>
        <!-- 状态说明 -->
        <div class="m-1"></div><span style="margin-left:6px;font-size:18px">驳回</span>
        <div class="m-2"></div><span style="margin-left:6px;font-size:18px">通过</span>
        <div class="m-3"></div><span style="margin-left:6px;font-size:18px">待审批</span>
        <!-- 数据 -->
        <el-table :data="leaveList"
            class="el-table-box"
            style="width: 100%; margin-top:20px;font-weight:700"
            :header-cell-style="{textAlign: 'center'}"
            :cell-style="{ textAlign: 'center' }"
            :row-class-name="tableRowClassName"
            max-height="80%">
            <el-table-column type="index" label="序号"  width="80"></el-table-column>
            <el-table-column prop="applyName" label="申请人姓名" width="100"></el-table-column>
            <el-table-column prop="applyTitle" label="标题" width="150"></el-table-column>
            <el-table-column prop="applyDetail" label="内容" width="250"></el-table-column>
            <el-table-column prop="applyType" label="类型" width="90"></el-table-column>
            <el-table-column prop="state" label="申请状态" width="180"></el-table-column>
            <el-table-column prop="beginDate" label="开始日期" width="180"></el-table-column>
            <el-table-column prop="endDate" label="结束日期" width="180"></el-table-column>
            <el-table-column prop="rejectMemo" label="驳回原因" width="250"></el-table-column>
            <el-table-column prop="approvalName" label="审批人" width="100"></el-table-column>
            <el-table-column
                fixed="right"
                label="操作"
                width="100">
                <template slot-scope="scope">
                    <el-button @click="lookQuitProcess(scope.row)" type="success" size="small" style="font-size:15px">查看</el-button>
                </template>
            </el-table-column>           
        </el-table>
        <!-- 查看 -->
        <el-dialog
            title="审批进度条"
            :visible.sync="processVisible"
            width="60%">
            <el-steps :active="active" :finish-status="finshState" align-center>
                <el-step title="待审批" ></el-step>              
                <el-step title="已完成" ></el-step>
                <el-step title="申请驳回" :description="rejectReason"></el-step>
            </el-steps>
            <span slot="footer" class="dialog-footer">
                <el-button @click="processVisible = false">取 消</el-button>
                <el-button type="primary" @click="processVisible = false">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
export default {
    data(){
        return{
            leaveList:[],
            processVisible:false,
            active:0,
            rejectReason:'',
            finshState:''
        }
    },
    created(){
        this.getLeaveData();
    },
    methods:{
        //获取数据
        getLeaveData(){
            this.$http.get("/approval/findLeaveApplyList").then((res)=>{
                // console.log(res);
                if(res.code === 200){
                    this.leaveList = res.data;
                }else{
                    this.$message.error("获取请假数据失败!!!");
                }
            }).catch((err)=>{
                this.$message.error("获取请假数据失败!!!");
            });
        },
        //某一行添加样式
        tableRowClassName({row, rowIndex}) {
            // console.log(typeof row.stateId);
            if (row.stateId === "2") {
                //通过
                return 'success-row';
            } else if (row.stateId === '3') {
                //驳回
                return 'error-row';
            }
            return '';
        },
        //查看进度
        lookQuitProcess(row){
            //转换为数字
            this.active = row.stateId - 0;
            if(row.stateId === '1'){
                this.finshState = 'finish';
            }else if(row.stateId === '2'){
                this.finshState = 'success';
            }else if(row.stateId === '3'){
                this.finshState = 'error';
            }
            this.rejectReason = row.rejectMemo;
            this.processVisible = true;
        }
    }
}
</script>

<style scoped>
.el-table >>> .error-row {
    background: #E6A23C;
}

.el-table >>> .success-row {
    background: #61e861;
}
.m-1{
    width: 15px;
    height: 15px;
    border: 1px solid rgb(230, 162, 60);
    display: inline-block;
    margin-top: 20px;
    margin-left: 35%;
    background-color:rgb(230, 162, 60);
}
.m-2{
    width: 15px;
    height: 15px;
    border: 1px solid rgb(97, 232, 97);
    display: inline-block;
    margin-top: 20px;
    margin-left: 5%;
    background-color:rgb(97, 232, 97);
}
.m-3{
    width: 15px;
    height: 15px;
    border: 1px solid black;
    display: inline-block;
    margin-top: 20px;
    margin-left: 5%;
    background-color:rgb(255, 255, 255);
}
</style>